<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>测试</title>
</head>
<body>
    <div id="app">
        <span>{{message}}</span>
        <span v-if="ifa">a</span>
        <span v-if="ifb">b</span>
        <span v-if="ifc">c</span>
        <span v-if="ifd">d</span>
        <ul>
            <li v-for="a in arraya">{{a}}</li>
        </ul>
        <ul>
            <li v-for="b in arrayb">
                用户的id为：{{b.id}}<br>
                用户的姓名为：{{b.name}}
            </li>
        </ul>
        <input type="text" v-model="inputValue">
        <button v-on:click="test1()">test1</button>
        <button v-on:click="test1()">test2</button>

    </div>

</body>
<script src="../js/vue.js"></script>
<script>
    let app = new  Vue({
        el: "#app",
        data:{
            message:"hello world",
            ifa:true,
            ifb:false,
            ifc:"abc",
            ifd:"",
            arraya:[1,2,3],
            arrayb:[
                {
                    id:1,
                    name:"first",
                },
                {
                    id:2,
                    name:"second",
                },
            ],
            inputValue:"文本框初始值",
        },
        methods:{
            test1:function (){
                // alert("test1")
                app.arrayb=[
                    {
                        id:3,
                        name:"three",
                    },
                    {
                        id:4,
                        name:"four",
                    },
                ];
            },
            test2:function (){
                // alert("test2")
                app.arrayb
            }
        }
    });
</script>
</html>